<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <!--
                                Charisma v1.0.0
                
                                Copyright 2012 Muhammad Usman
                                Licensed under the Apache License v2.0
                                http://www.apache.org/licenses/LICENSE-2.0
                
                                http://usman.it
                                http://twitter.com/halalit_usman
        -->
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Gerente - Processos</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <meta name="description"
                  content="Charisma, a fully featured, responsive, HTML5, Bootstrap admin template.">
                <meta name="author" content="Muhammad Usman">

                    <!-- The styles -->
                    <link id="bs-css" href="css/bootstrap-cerulean.css" rel="stylesheet">
                        <style type="text/css">
                            body {
                                padding-bottom: 40px;
                            }

                            .sidebar-nav {
                                padding: 9px 0;
                            }
                        </style>
                        <link href="css/bootstrap-responsive.css" rel="stylesheet" />
                        <link href="css/charisma-app.css" rel="stylesheet" />
                        <link href="css/jquery-ui-1.8.21.custom.css" rel="stylesheet" />
                        <link href='css/fullcalendar.css' rel='stylesheet' />
                        <link href='css/fullcalendar.print.css' rel='stylesheet' media='print' />
                        <link href='css/chosen.css' rel='stylesheet' />
                        <link href='css/uniform.default.css' rel='stylesheet' />
                        <link href='css/colorbox.css' rel='stylesheet' />
                        <link href='css/jquery.cleditor.css' rel='stylesheet' />
                        <link href='css/jquery.noty.css' rel='stylesheet' />
                        <link href='css/noty_theme_default.css' rel='stylesheet' />
                        <link href='css/elfinder.min.css' rel='stylesheet' />
                        <link href='css/elfinder.theme.css' rel='stylesheet' />
                        <link href='css/jquery.iphone.toggle.css' rel='stylesheet' />
                        <link href='css/opa-icons.css' rel='stylesheet' />
                        <link href='css/uploadify.css' rel='stylesheet' />

                        <!-- JqGrig -->
                        <link rel="stylesheet" type="text/css" media="screen"
                              href="jqGrid/css/ui.jqgrid.css" />
                        <!------------>

                        <!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
                        <!--[if lt IE 9]>
                                                          <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
                                                        <![endif]-->

                        <!-- The fav icon -->
                        <link rel="shortcut icon" href="img/favicon.ico">

                            </head>

                            <body>
                                <!-- topbar starts -->
                                <div class="navbar">
                                    <div class="navbar-inner">
                                        <div class="container-fluid">
                                            <a class="btn btn-navbar" data-toggle="collapse"
                                               data-target=".top-nav.nav-collapse,.sidebar-nav.nav-collapse">
                                                <span class="icon-bar"></span> <span class="icon-bar"></span> <span
                                                    class="icon-bar"></span>
                                            </a> <a class="brand" href="gerente.html"><span>Gerente</span></a>

                                            <!-- theme selector starts -->
                                            <div class="btn-group pull-right theme-container">
                                                <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
                                                    <i class="icon-tint"></i><span class="hidden-phone">
                                                        Alterar Cor</span> <span class="caret"></span>
                                                </a>
                                                <ul class="dropdown-menu" id="themes">
                                                    <li><a data-value="classic" href="#"><i
                                                                class="icon-blank"></i> Padrão</a></li>
                                                    <li><a data-value="cerulean" href="#"><i
                                                                class="icon-blank"></i> Azul Claro</a></li>
                                                    <li><a data-value="cyborg" href="#"><i class="icon-blank"></i>
                                                            Preto</a></li>
                                                    <li><a data-value="redy" href="#"><i class="icon-blank"></i>
                                                            Vermelho</a></li>
                                                    <li><a data-value="journal" href="#"><i
                                                                class="icon-blank"></i> Branco</a></li>
                                                    <li><a data-value="simplex" href="#"><i
                                                                class="icon-blank"></i> Simples</a></li>
                                                    <li><a data-value="slate" href="#"><i class="icon-blank"></i>
                                                            Cinza Escuro</a></li>
                                                    <li><a data-value="united" href="#"><i class="icon-blank"></i>
                                                            Laranja</a></li>
                                                </ul>
                                            </div>
                                            <!-- theme selector ends -->

                                            <!-- user dropdown starts -->
                                            <div class="btn-group pull-right">
                                                <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
                                                    <i class="icon-user"></i><span class="hidden-phone"> Conta</span>
                                                    <span class="caret"></span>
                                                </a>
                                                <ul class="dropdown-menu">
                                                    <li><a href="index.html">Sair</a></li>
                                                </ul>
                                            </div>
                                            <!-- user dropdown ends -->
                                            <!-- Usuarios -->
                                            <div class="btn-group pull-right">
                                                <ul class="dropdown-menu">
                                                    <li><a class="btn-setting">Cadastrar</a></li>
                                                </ul>
                                            </div>
                                            <!-- End Usuarios -->
                                        </div>
                                    </div>
                                </div>
                                <!-- topbar ends -->
                                <div class="container-fluid">
                                    <div class="row-fluid">

                                        <div class="span2 main-menu-span">
                                            <div class="well nav-collapse sidebar-nav">
                                                <ul class="nav nav-tabs nav-stacked main-menu">
                                                    <li class="nav-header hidden-tablet">Menu Principal</li>
                                                    <li><a class="ajax-link" href="gerenteEscritorio.html"><i
                                                                class="icon-user"></i><span class="hidden-tablet">
                                                                Escrit&oacute;rio</span></a></li>
                                                    <li><a class="ajax-link" href="gerenteAdvogado.html"><i
                                                                class="icon-user"></i><span class="hidden-tablet">
                                                                Advogados</span></a></li>
                                                    <li><a class="ajax-link" href="gerenteSecretaria.html"><i
                                                                class="icon-user"></i><span class="hidden-tablet">
                                                                Secret&aacute;rias</span></a></li>
                                                    <li><a class="ajax-link" href="gerenteEstagiario.html"><i
                                                                class="icon-user"></i><span class="hidden-tablet">
                                                                Estagi&aacute;rios</span></a></li>
                                                    <li><a class="ajax-link" href="gerenteProcesso.html"><i
                                                                class="icon-list-alt"></i><span class="hidden-tablet">
                                                                Processos</span></a></li>
                                                    <li><a class="ajax-link" href="gerenteCliente.html"><i
                                                                class="icon-user"></i><span class="hidden-tablet">
                                                                Clientes</span></a></li>
                                                </ul>
                                            </div>
                                            <!--/.well -->
                                        </div>
                                        <!--/span-->
                                        <!--/span-->
                                        <!-- left menu ends -->

                                        <div id="content" class="span10">
                                            <!-- content starts -->
                                             <div class="sortable row-fluid">
                        <a data-rel="tooltip" title="advogados cadastrados"
                           class="well span3 top-block" href="#"> <span
                                class="icon32 icon-red icon-user"></span>
                            <div>Advogados no escrit&oacute;rio</div>
                            <span class="notification" id="notification-advogados-escritorio"></span>
                        </a> <a data-rel="tooltip" title="Secretarias(os)"
                                class="well span3 top-block" href="#"> <span
                                class="icon32 icon-color icon-star-on"></span>
                            <div>Secret&aacute;rias(os) no escrit&oacute;rio</div>
                             <span class="notification green" id="notication-total-secretarias-escritorio"></span>
                        </a> <a data-rel="tooltip"
                                title="clientes com processos no escrit&oacute;rio"
                                class="well span3 top-block" href="#"> <span
                                class="icon32 icon-color icon-home"></span>
                            <div>Clientes</div>
                            <span class="notification yellow" id="notication-total-clientes-escritorio"></span>
                        </a> <a data-rel="tooltip" title="Processos cadastrados"
                                class="well span3 top-block" href="#"> <span
                                class="icon32 icon-color icon-book"></span>
                            <div>Processos Cadastrados</div>
                            <span class="notification red" id="notication-total-processos-escritorio"></span>
                        </a>
                    </div>
                                            <div class="row-fluid sortable">
                                                <div class="box span12">
                                                    <div class="box-header well" data-original-title>
                                                        <h2>
                                                            <i class="icon-user"></i>Processos
                                                        </h2>
                                                        <div class="box-icon">
                                                            <a href="#" class="btn btn-minimize btn-round"><i
                                                                    class="icon-chevron-up"></i></a>
                                                        </div>
                                                    </div>
                                                    <div id="div_tb_clientes" class="box-content">
                                                        <button type="button" class="btn btn-info btn-setting"
                                                                style="width: 10%">Cadastrar processo</button>
                                                        <br /> <br />

                                                        <table id="tb_clientes"></table>
                                                        <div id="pager_tb_clientes"></div>
                                                        <input type="button" id="bsdata" value="Filtrar" />
                                                        <input type="button" id="btnExportExcel" value="Exportar Excel"
                                                               onclick="exportExcel()" />
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <hr>
                                        <!-- Caixas de confirmação para deleção -->
                                        <div class="modal hide fade" id="confirm-delete"
                                             style="width: 256px; left: 60%;">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal">×</button>
                                                <h3>Exclusão de Processo</h3>
                                            </div>
                                            <div class="modal-body">
                                                <p>Deseja excluir este processo?</p>
                                            </div>
                                            <div class="modal-footer">
                                                <a href="#" class="btn btn-success" data-dismiss="modal"> <i
                                                        class="icon icon-white icon-close"></i> Não
                                                </a> <a href="#" class="btn btn-danger" data-dismiss="modal"
                                                        onclick='deleteProcesso(deleteProcessoID)'> <i
                                                        class="icon icon-white icon-trash"></i> Sim
                                                </a>
                                            </div>
                                        </div>

                                        <div class="modal hide fade" id="confirm-block"
                                             style="width: 256px; left: 60%;">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal">×</button>
                                                <h3>Bloqueio de processo</h3>
                                            </div>
                                            <div class="modal-body">
                                                <p>Deseja bloquear este processo?</p>
                                            </div>
                                            <div class="modal-footer">
                                                <a href="#" class="btn btn-success" data-dismiss="modal"> <i
                                                        class="icon icon-white icon-close"></i> Não
                                                </a> <a href="#" class="btn btn-danger" data-dismiss="modal"> <i
                                                        class="icon-lock icon-white"></i> Sim
                                                </a>
                                            </div>
                                        </div>
                                        <!-- Fim das caixas -->
                                        <footer>
                                            <p class="pull-left">
                                                &copy; <a href="#" target="_blank">Bacharel 6º Ciclo FATEC
                                                    Carapicuíba</a> 2012
                                            </p>
                                        </footer>

                                </div>
                                <!--/.fluid-container-->
                                <!-- Formulário de edição de usuário
                                                                        Melhora: Passar página para .php e usar include evitando repetir este código em todas as páginas
                                -->
                                <!-- Cadastrar -->
                                <div class="modal hide fade" id="myModal">
                                    <div class="modal-body" style="min-height: 0px">
                                        <div class="row-fluid sortable">
                                            <div class="box-content">
                                                <form class="form-horizontal" name="formCadastro">
                                                    <fieldset>
                                                        <input type="hidden" id="csvBuffer"
                                                               name="csvBuffer" />
                                                        <div class="control-group">
                                                            <label class="control-label" for="tipoAcaoProcessoCadastro">Tipo
                                                                ação</label>
                                                            <div class="controls">
                                                                <input class="input-xlarge focused"
                                                                       id="tipoAcaoProcessoCadastro" maxlength="50" type="text">
                                                            </div>
                                                        </div>
                                                        <div class="control-group">
                                                            <label class="control-label"
                                                                   for="parteContrariaProcessoCadastro">Parte contraria</label>
                                                            <div class="controls">
                                                                <input class="input-xlarge focused"
                                                                       id="parteContrariaProcessoCadastro" maxlength="50" type="text">
                                                            </div>
                                                        </div>
                                                        <div class="control-group">
                                                            <label class="control-label" for="varaProcessoCadastro">Vara</label>
                                                            <div class="controls">
                                                                <input class="input-xlarge focused" id="varaProcessoCadastro"
                                                                       maxlength="50" type="text">
                                                            </div>
                                                        </div>
                                                        <div class="control-group">
                                                            <label class="control-label" for="numProcessoCadastro">Numero
                                                                do processo</label>
                                                            <div class="controls">
                                                                <input class="input-xlarge focused" id="numProcessoCadastro"
                                                                       maxlength="50" type="text">
                                                            </div>
                                                        </div>
                                                        <div class="control-group">
                                                            <label class="control-label">Permissões</label>
                                                            <div class="controls">
                                                                <label class="checkbox inline">
                                                                    <input type="checkbox" id="chkAdvogado" value="1"> Advogado
                                                                </label>
                                                                <label class="checkbox inline">
                                                                    <input type="checkbox" id="chkSecretaria" value="1"> Secretária
                                                                </label>
                                                                <label class="checkbox inline">
                                                                    <input type="checkbox" id="chkEstagiario" value="1"> Estagiário
                                                                </label>
                                                            </div>
                                                        </div>
                                                    </fieldset>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                        <a href="#" class="btn" data-dismiss="modal" onclick="redirect()">Fechar</a>
                                        <a href="#" class="btn btn-primary"
                                           onclick="return submitCadastroProcesso();">Cadastrar</a>
                                    </div>
                                </div>
                                <!-- Editar -->
                                <div class="modal hide fade" id="edit_cliente">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal">×</button>
                                        <h3>Editar processo</h3>
                                    </div>
                                    <div class="modal-body" style="min-height: 0px">
                                        <div class="row-fluid sortable">
                                            <div class="box-content">
                                                <form class="form-horizontal" name="formUpdate">
                                                    <fieldset>
                                                        <!-- Cadastrar -->
                                                        <div class="modal hide fade" id="myModal">
                                                            <div class="modal-body" style="min-height: 0px">
                                                                <div class="row-fluid sortable">
                                                                    <div class="box-content">
                                                                        <form class="form-horizontal" name="formCadastro">
                                                                            <fieldset>
                                                                                <div class="control-group">
                                                                                    <label class="control-label" for="tipoAcaoProcessoCadastro">Tipo
                                                                                        ação</label>
                                                                                    <div class="controls">
                                                                                        <input class="input-xlarge focused"
                                                                                               id="tipoAcaoProcessoCadastro" maxlength="50" type="text">
                                                                                    </div>
                                                                                </div>
                                                                                <div class="control-group">
                                                                                    <label class="control-label"
                                                                                           for="parteContrariaProcessoCadastro">Parte contraria</label>
                                                                                    <div class="controls">
                                                                                        <input class="input-xlarge focused"
                                                                                               id="parteContrariaProcessoCadastro" maxlength="50" type="text">
                                                                                    </div>
                                                                                </div>
                                                                                <div class="control-group">
                                                                                    <label class="control-label" for="varaProcessoCadastro">Vara</label>
                                                                                    <div class="controls">
                                                                                        <input class="input-xlarge focused" id="varaProcessoCadastro"
                                                                                               maxlength="50" type="text">
                                                                                    </div>
                                                                                </div>
                                                                                <div class="control-group">
                                                                                    <label class="control-label" for="numProcessoCadastro">Numero
                                                                                        do processo</label>
                                                                                    <div class="controls">
                                                                                        <input class="input-xlarge focused" id="numProcessoCadastro"
                                                                                               maxlength="50" type="text">
                                                                                    </div>
                                                                                </div>
                                                                            </fieldset>
                                                                        </form>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="modal-footer">
                                                                <a href="#" class="btn" data-dismiss="modal" onclick="redirect()">Fechar</a>
                                                                <a href="#" class="btn btn-primary"
                                                                   onclick="return submitCadastroProcesso();">Cadastrar</a>
                                                            </div>
                                                        </div>
                                                        <!-- Editar -->
                                                        <div class="modal hide fade" id="edit_cliente">
                                                            <div class="modal-header">
                                                                <button type="button" class="close" data-dismiss="modal">×</button>
                                                                <h3>Editar processo</h3>
                                                            </div>
                                                            <div class="modal-body" style="min-height: 0px">
                                                                <div class="row-fluid sortable">
                                                                    <div class="box-content">
                                                                        <form class="form-horizontal" name="formUpdate">
                                                                            <fieldset>
                                                                                <div class="control-group">
                                                                                    <label class="control-label" for="tipoAcaoProcesso">Tipo
                                                                                        ação</label>
                                                                                    <div class="controls">
                                                                                        <input class="input-xlarge focused" id="tipoAcaoProcesso"
                                                                                               maxlength="50" type="text" value="X"
                                                                                               onBlur="trim(formUpdate.tipoAcaoProcesso)">
                                                                                    </div>
                                                                                </div>
                                                                                <div class="control-group">
                                                                                    <label class="control-label" for="parteContrariaProcesso">Parte
                                                                                        Contraria</label>
                                                                                    <div class="controls">
                                                                                        <input class="input-xlarge focused" id="parteContrariaProcesso"
                                                                                               onBlur="trim(formUpdate.parteContrariaProcesso)"
                                                                                               maxlength="80" type="text">
                                                                                    </div>
                                                                                </div>
                                                                                <div class="control-group">
                                                                                    <label class="control-label" for="varaProcesso">Vara </label>
                                                                                    <div class="controls">
                                                                                        <input class="input-xlarge focused" id="varaProcesso"
                                                                                               onBlur="trim(formUpdate.varaProcesso)" maxlength="35"
                                                                                               type="text">
                                                                                    </div>
                                                                                </div>
                                                                                <div class="control-group">
                                                                                    <label class="control-label" for="numProcesso">Numero do
                                                                                        processo</label>
                                                                                    <div class="controls">
                                                                                        <input class="input-xlarge focused" id="numProcesso"
                                                                                               onBlur="trim(formUpdate.numProcesso)" maxlength="9"
                                                                                               type="text">
                                                                                    </div>
                                                                                </div>
                                                                            </fieldset>
                                                                        </form>
                                                                    </div>
                                                                </div>
                                                                <!--/row-->
                                                            </div>
                                                            <div class="modal-footer">
                                                                <a href="#" class="btn" data-dismiss="modal">Cancelar</a> <a href="#"
                                                                                                                             class="btn btn-primary" data-dismiss="modal"
                                                                                                                             onclick="updateProcesso(updateProcessoId)">Atualizar</a>
                                                            </div>
                                                        </div>
                                                        <!-- Formulário de edição de usuário -->

                                                        <!-- external javascript
                                                                                ================================================== -->
                                                        <!-- Placed at the end of the document so the pages load faster -->

                                                        <!-- jQuery -->
                                                        <script src="js/jquery-1.7.2.min.js"></script>
                                                        <!-- jQuery UI -->
                                                        <script src="js/jquery-ui-1.8.21.custom.min.js"></script>
                                                        <!-- transition / effect library -->
                                                        <script src="js/bootstrap-transition.js"></script>
                                                        <!-- alert enhancer library -->
                                                        <script src="js/bootstrap-alert.js"></script>
                                                        <!-- modal / dialog library -->
                                                        <script src="js/bootstrap-modal.js"></script>
                                                        <!-- custom dropdown library -->
                                                        <script src="js/bootstrap-dropdown.js"></script>
                                                        <!-- scrolspy library -->
                                                        <script src="js/bootstrap-scrollspy.js"></script>
                                                        <!-- library for creating tabs -->
                                                        <script src="js/bootstrap-tab.js"></script>
                                                        <!-- library for advanced tooltip -->
                                                        <script src="js/bootstrap-tooltip.js"></script>
                                                        <!-- popover effect library -->
                                                        <script src="js/bootstrap-popover.js"></script>
                                                        <!-- button enhancer library -->
                                                        <script src="js/bootstrap-button.js"></script>
                                                        <!-- accordion library (optional, not used in demo) -->
                                                        <script src="js/bootstrap-collapse.js"></script>
                                                        <!-- carousel slideshow library (optional, not used in demo) -->
                                                        <script src="js/bootstrap-carousel.js"></script>
                                                        <!-- autocomplete library -->
                                                        <script src="js/bootstrap-typeahead.js"></script>
                                                        <!-- tour library -->
                                                        <script src="js/bootstrap-tour.js"></script>
                                                        <!-- library for cookie management -->
                                                        <script src="js/jquery.cookie.js"></script>
                                                        <!-- calander plugin -->
                                                        <script src='js/fullcalendar.js'></script>
                                                        <!-- data table plugin -->
                                                        <script src='js/jquery.dataTables.min.js'></script>

                                                        <!-- chart libraries start -->
                                                        <script src="js/excanvas.js"></script>
                                                        <script src="js/jquery.flot.min.js"></script>
                                                        <script src="js/jquery.flot.pie.min.js"></script>
                                                        <script src="js/jquery.flot.stack.js"></script>
                                                        <script src="js/jquery.flot.resize.min.js"></script>
                                                        <!-- chart libraries end -->

                                                        <!-- select or dropdown enhancer -->
                                                        <script src="js/jquery.chosen.min.js"></script>
                                                        <!-- checkbox, radio, and file input styler -->
                                                        <script src="js/jquery.uniform.min.js"></script>
                                                        <!-- plugin for gallery image view -->
                                                        <script src="js/jquery.colorbox.min.js"></script>
                                                        <!-- rich text editor library -->
                                                        <script src="js/jquery.cleditor.min.js"></script>
                                                        <!-- notification plugin -->
                                                        <script src="js/jquery.noty.js"></script>
                                                        <!-- file manager library -->
                                                        <script src="js/jquery.elfinder.min.js"></script>
                                                        <!-- star rating plugin -->
                                                        <script src="js/jquery.raty.min.js"></script>
                                                        <!-- for iOS style toggle switch -->
                                                        <script src="js/jquery.iphone.toggle.js"></script>
                                                        <!-- autogrowing textarea plugin -->
                                                        <script src="js/jquery.autogrow-textarea.js"></script>
                                                        <!-- multiple file upload plugin -->
                                                        <script src="js/jquery.uploadify-3.1.min.js"></script>
                                                        <!-- history.js for cross-browser state change on ajax -->
                                                        <script src="js/jquery.history.js"></script>
                                                        <!-- application script for Charisma demo -->
                                                        <script src="js/charisma.js"></script>
                                                        <script src="js/jquery.validaCampos.js"></script>
                                                        <!-- jqGrid -->
                                                        <script src="jqGrid/js/i18n/grid.locale-pt-br.js"
                                                        type="text/javascript"></script>
                                                        <script src="jqGrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
                                                        <script src="js/jquery.ui.datepicker-pt-BR.js"></script>
                                                        <script src="js/cadastro-usuario.js"></script>
<script type="text/javascript">
		$(function() {
			jQuery.get('../index.php?notificacao/totalAdvogadosEscritorio', {}, function(ret) {
				document.getElementById('notification-advogados-escritorio').innerHTML = ret;
			}, "html");
			jQuery.get('../index.php?notificacao/totalSecretariasEscritorio',{},function(ret) {
				document.getElementById('notication-total-secretarias-escritorio').innerHTML = ret;
			}, "html");
			jQuery.get('../index.php?notificacao/totalClientesEscritorio',{},function(ret) {
				document.getElementById('notication-total-clientes-escritorio').innerHTML = ret;
			}, "html");
			jQuery.get('../index.php?notificacao/totalProcessosEscritorio',{},function(ret) {
				document.getElementById('notication-total-processos-escritorio').innerHTML = ret;
			}, "html");
			jQuery.get('../index.php?notificacao/getCodigoEscritorio',{},function(ret) {
				document.getElementById('notification-code-escritorio').innerHTML = "escrit&oacute;rio : " + ret;
			}, "html");
			jQuery.get('../index.php?notificacao/getCodigoGerente',{},function(ret) {
				document.getElementById('notification-code-gerente').innerHTML = "C&oacute;digo de gerente : " + ret;
			}, "html");
			
		});
	</script>
                                                        <script type="text/javascript">				// Url usada para deletar os processos
                                                            var deleteURL = "../index.php?processo/removerProcesso";
                                                            // Url usada para atualizar dados do processo
                                                            var updateURL = "../index.php?processo/atualizarProcesso";
                                                            // Url usada para adquirir lista de processos (todos)
                                                            var listProcesso = "../index.php?processo/listAllByUsuario";
                                                            // Url que traz todos os dados do processo para exibição no form de edição
                                                            var getProcessoDataURL = "../index.php?processo/getProcesso";
				
				
                                                            var ativarStatusProcessoURL = "../index.php?processo/ativarProcesso";
				
                                                            var inativarStatusProcessoURL = "../index.php?processo/inativarProcesso";
                                                            <!-------------------------------------------------------------------->

                                                            // Id do usuário usado para deleção
                                                            var deleteProcessoID = -1;
                                                            // Id do usuário usado para atualização
                                                            var updateProcessoId = -1;
                                                        </script>
                                                        <script type="text/javascript">
                                                            $(function() {
                                                                $.datepicker.setDefaults($.datepicker.regional["pt-BR"]);
                                                            });
                                                        </script>
                                                        <!-- Tabela jqGrid -->
                                                        <script type="text/javascript">
                                                            $(document).ready(function(){
                                                                $("#tb_clientes").jqGrid({
                                                                    url:listProcesso,
                                                                    datatype:"json",
                                                                    height: 210,
                                                                    colNames: ["id", "Tipo Ação", "Parte contraria", "Vara", "Numero de processo","cliente", "Status", "Ações"],
                                                                    colModel: [
                                                                        {name:"id", hidden:true, key: true},
                                                                        {name:"tipo_acao", resizeable:true, sortable: true, width: 80},
                                                                        {name:"parte_contraria", resizeable:true, sortable: true, width: 100},
                                                                        {name:"vara", resizeable:true, sortable: true,width: 80},
                                                                        {name:"num_processo", resizeable:true, sortable: true, width: 130},
                                                                        {name:"nome_clientes", resizeable:true, sortable: true, width: 130},
                                                                        {name:"status", resizeable:true, sortable: true, width:60},
                                                                        {name:"acoes", resizeable:false, sortable: false, width:80}
                                                                    ],
                                                                    autowidth:true,
                                                                    rowNum: 10,
                                                                    gridComplete: function(){ 
                                                                        var ids = $("#tb_clientes").getDataIDs(); // Pega os IDs das linhas
                                                                        for(var i=0;i<ids.length;i++){
                                                                            // Pega id do usuário
                                                                            // 							alert($("#tb_clientes").jqGrid('getRowData', ids[i]).id);
                                                                            // Modifica o campo acoes de todas as linhas inserindo os botões customizados
                                                                            $("#tb_clientes").jqGrid('setRowData',ids[i],{acoes:"<a  class='btn btn-success' title='Eventos' href='gerenteEvento.html?id_processo="+ids[i]+"'><i class='icon-lock icon-white'></i></a><a  class='btn btn-warning' title='Clientes relacionados' href='gerenteClienteProcesso.html?id_processo="+ids[i]+"'><i class='icon-user icon-white'></i></a><a title='Editar' class='btn btn-info' href='#' onclick=showUpdateForm("+ids[i]+")><i class='icon-edit icon-white'></i></a><a title='Remover' class='btn btn-danger' href='#' onclick=showConfirmDelete("+ids[i]+")><i class='icon-trash icon-white'></i></a>"});
                                                                            // Modifica os campos de texto com ativo/inativo
                                                                            if(parseInt($("#tb_clientes").jqGrid('getRowData', ids[i]).status) == 1)
                                                                                $("#tb_clientes").jqGrid('setRowData', ids[i], {status:"<span class='label label-success'  onclick='inativarStatusProcesso("+ids[i]+")' >Ativo</span>"});
                                                                            else
                                                                                $("#tb_clientes").jqGrid('setRowData', ids[i], {status:"<span class='label label-warning' onclick='ativarStatusProcesso("+ids[i]+")'>Inativo</span>"});
                                                                        } 
                                                                    },
                                                                    //multiselect: true, // Também podemos tirar os botões de cada linha e utilizar um sistema de multiseleção e usar apenas três botões
                                                                    pager:$("#pager_tb_clientes")
                                                                }).navGrid("#pagerTbClientes", {edit:false, add:false, del:false});
                                                            });
                                                            $(window).resize(function(){
                                                                var width = document.getElementById("div_tb_clientes").offsetWidth;
                                                                $("#tb_clientes").setGridWidth(width-20);
                                                            });
                                                            $("#bsdata").click(function(){
                                                                jQuery("#tb_clientes").jqGrid('searchGrid',
                                                                {sopt:['cn','eq'],width:800}
                                                            );
                                                            });
			
                                                            function ativarStatusProcesso(id){
                                                                jQuery.get(ativarStatusProcessoURL, {id_processo:id+""}, function(ret){}, "html");	
                                                                $("#tb_clientes").trigger('reloadGrid');
                                                            }
			
                                                            function inativarStatusProcesso(id){
                                                                jQuery.get(inativarStatusProcessoURL, {id_processo:id+""}, function(ret){}, "html");	
                                                                // 				console.info (inativarStatusProcessoURL);
				
                                                                $("#tb_clientes").trigger('reloadGrid');
                                                            }
			
			
                                                            function showConfirmDelete(id) {
                                                                deleteProcessoID = id;
                                                                $("#confirm-delete").modal('show');
                                                            }
                                                            function showUpdateForm(processoId) {
                                                                updateProcessoId = processoId;

                                                                jQuery.get(getProcessoDataURL, {id_processo:processoId}, function(ret){
                                                                    /**
                                                                                                                        ['id_processo'],
                                                                                                                        ['tipo_acao'],
                                                                                                                        ['parte_contraria'],
                                                                                                                        ['vara'],
                                                                                                                        ['num_processo'],
                                                                                                                        ['cliente']
                                                                                                                        ['status'],
                                                                     */
                                                                    document.getElementById('tipoAcaoProcesso').value = ret[1];
                                                                    document.getElementById('parteContrariaProcesso').value = ret[2];
                                                                    document.getElementById('varaProcesso').value = ret[3];
                                                                    document.getElementById('numProcesso').value = ret[4];
                                                                    $("#edit_cliente").modal('show');
                                                                },
                                                                "json");
                                                            }
                                                            function updateProcesso(processoId) {
                                                                jQuery.get(updateURL, {
                                                                    id_processo:processoId+"",
                                                                    tipo_acao:document.getElementById('tipo_acao').value,
                                                                    parte_contraria:document.getElementById('parte_contraria').value,
                                                                    vara:document.getElementById('vara').value,
                                                                    num_processo:document.getElementById('num_processo').value
                                                                }, function(ret){}, "html");
                                                                $("#tb_clientes").trigger('reloadGrid');
                                                            }
                                                            function exportExcel()
                                                            {
                                                                var mya=new Array();
                                                                mya=$("#tb_clientes").getDataIDs();  // Get All IDs
                                                                var data=$("#tb_clientes").getRowData(mya[0]);     // Get First row to get the labels
                                                                var colNames=new Array(); 
                                                                var ii=0;
                                                                for (var i in data){
                                                                    colNames[ii++]=i;
                                                                }    // capture col names
                                                                var html="";
	                
                                                                for(i=0;i<mya.length;i++){
                                                                    data=$("#tb_clientes").getRowData(mya[i]); // get each row
                                                                    for(j=0;j<colNames.length;j++)
                                                                    {
                                                
                                                                        if (colNames[j] == "status"){
                                                                            console.info (data[colNames[j]]);
                                                                            if (data[colNames[j]].indexOf("Ativo") !== -1){
                                                                                html=html + " ativo " + "\t";    
                                                                            }else{
                                                                                html=html + " inativo " + "\t";  
                                                                            }
                                                                        }else if (colNames[j] == "acoes"){
                                                                            html=html + " " + "\t"; 	
                                                                        }else{
                                                                            html=html+data[colNames[j]]+"\t"; 
                                                                        }
                                                                    }
                                                                    html=html+"\n"; 
                                                                }
                                                                console.info(html);
                                        
                                                                document.forms[0].csvBuffer.value=html;
                                                                document.forms[0].method='POST';
                                                                document.forms[0].action='../controllers/exportExcel.php'; 
                                                                document.forms[0].target='_blank';
                                                                document.forms[0].submit();
                                                            }
                                                            function deleteProcesso(processoId) {
                                                                jQuery.get(deleteURL, {id_processo:processoId+""}, function(ret){}, "html");
                                                                $("#tb_clientes").trigger('reloadGrid');
                                                            }
                                                            function isEmpty(field) {
                                                                if (isValid == 0)
                                                                    return;
                                                                if (field.value.length == 0) {
                                                                    alert("O campo nao pode ser vazio");
                                                                    field.focus();
                                                                    isValid = 0;
                                                                }

                                                            }
                                                            function redirect() {
                                                                window.location.href = "gerenteProcesso.html";
                                                            }
                                                            function submitCadastroProcesso() {
                                                                isValid = 1;
                                                                // 				['tipo_acao'],
                                                                // 				['parte_contraria'],
                                                                // 				['vara'],
                                                                // 				['num_processo'],
                                                                var tipoAcao = document.getElementById('tipoAcaoProcessoCadastro');
                                                                var parteContraria = document.getElementById('parteContrariaProcessoCadastro');
                                                                var vara = document.getElementById('varaProcessoCadastro');
                                                                var numProcesso = document.getElementById('numProcessoCadastro');
                                                                var chkAdvogado = document.getElementById('chkAdvogado');
                                                                var chkSecretaria = document.getElementById('chkSecretaria');
                                                                var chkEstagiario = document.getElementById('chkEstagiario');
                                                                isEmpty(tipoAcao);
                                                                isEmpty(parteContraria);
                                                                isEmpty(vara);
                                                                isEmpty(numProcesso);
                                                                var isAdvogadoPermitido = 0;
                                                                var isSecretariaPermitido = 0;
                                                                var isEstagiarioPermitido = 0;
                                                                if(chkAdvogado.checked){
                                                                    isAdvogadoPermitido = 1;
                                                                }
                                                                if(chkEstagiario.checked){
                                                                    isEstagiarioPermitido = 1;
                                                                }
                                                                if(chkSecretaria.checked){
                                                                    isSecretariaPermitido = 1;
                                                                }
                                                                alert(isAdvogadoPermitido + " " + isEstagiarioPermitido + " " + isSecretariaPermitido);
                                                                if (!isValid)
                                                                    return false;
                                                                var urlCadastro = "../index.php?processo/salvar&tipo_acao="
                                                                    + tipoAcao.value
                                                                    + "&parte_contraria="
                                                                    + parteContraria.value
                                                                    + "&vara="
                                                                    + vara.value
                                                                    + "&num_processo="
                                                                    + numProcesso.value
                                                                    + "&advogado="
                                                                    + isAdvogadoPermitido
                                                                    + "&secretaria="
                                                                    + isSecretariaPermitido
                                                                    + "&estagiario="
                                                                    + isEstagiarioPermitido
                                                                $.ajax({
                                                                    url : urlCadastro,
                                                                    success : function(result) {
                                                                        var key = parseInt(result.replace(']', '').replace('[',
                                                                        ''));
                                                                        switch (key) {
                                                                            case 0:
                                                                                window
                                                                                .alert("Erro ao cadastrar processo. Entre em contato com o administrador do sistema.");
                                                                                break;
                                                                            case 1:
                                                                                window
                                                                                .alert("Processo cadastrado com sucesso.");
                                                                                break;
                                                                            default:
                                                                                window
                                                                                .alert("Erro ao cadastrar processo. Entre em contato com o administrador do sistema.");
                                                                                break;
                                                                        }
                                                                    },
                                                                    error : function(request, status, errorThrown) {
                                                                        alert("Erro ao cadastrar processo. Entre em contato com o administrador do sistema.");
                                                                    }
                                                                });
                                                            }
                                                        </script>
                                                        </body>
                                                        </html>
